package com.fitzone.web.controller.mini;

import com.fitzone.common.result.Result;
import com.fitzone.model.entity.Activity;
import com.fitzone.web.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/mini/activity")
@Api(tags = "小程序活动相关接口")
public class MiniActivityController {
    private final ActivityService activityService;

    @GetMapping("/list")
    @ApiOperation("活动推荐")
    public Result activityList(){

        List<Activity> list = activityService.list();
        for (Activity activity : list) {
            if (activity.getStatus() == 0) {
                return Result.fail();
            }
        }
        return Result.ok(list);
    }
}
